package com.atguigu.srb.core.controller.admin;


import com.atguigu.common.result.R;
import com.atguigu.srb.core.pojo.entity.Borrower;
import com.atguigu.srb.core.pojo.vo.BorrowerApprovalVO;
import com.atguigu.srb.core.pojo.vo.BorrowerDetailVO;
import com.atguigu.srb.core.service.BorrowerAttachService;
import com.atguigu.srb.core.service.BorrowerService;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.awt.*;

/**
 * <p>
 * 借款人 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-09-13
 */
@RestController
@RequestMapping("/admin/core/borrower")
public class AdminBorrowerController {
    @Resource
    BorrowerService borrowerService;

    @GetMapping("/getListPage/{page}/{limit}")
    public R getListPage(@PathVariable Long page,
                         @PathVariable Long limit,String keyword){
        Page<Borrower> borrowerPage = new Page<>();
        borrowerPage.setSize(limit);
        borrowerPage.setCurrent(page);
      IPage<Borrower> pageModel = borrowerService.getListPage(borrowerPage,keyword);
        return R.ok().data("pageModel",pageModel);
    }
   @GetMapping("/show/{id}")
    public R show(@PathVariable Long id){
       BorrowerDetailVO borrower = borrowerService.show(id);
        return R.ok().data("borrower",borrower);
   }
   @PostMapping("/approvalSubmit")
    public R approvalSubmit(@RequestBody BorrowerApprovalVO borrowerApprovalVO){
        borrowerService.approvalSubmit(borrowerApprovalVO);
        return R.ok();
   }
}

